import axios from '../axios';

/**
 * 获取手机验证码
 * @param phoneNum 手机号码
 * @returns {AxiosPromise}
 */
export const getCodeApi = (phoneNum) => axios({
    url: '/getCode',
    method: 'get',
    params: {
      phoneNum
    }
})

/**
 * 用户注册
 * @param registerForm 用户信息
 * @returns {AxiosPromise}
 */
export const registerApi = (registerForm) => axios({
    url: '/register',
    method: 'post',
    data: registerForm
})

/**
 * 校验账号
 * @param forgetForm 账号信息（手机号和验证码）
 * @returns {*}
 */
export const checkPhoneApi = (forgetForm) => axios({
    url: '/checkPhone',
    method: 'post',
    data: forgetForm
})

/**
 * 更新密码
 * @param forgetForm 密码信息
 * @returns {*}
 */
export const updateUserPassApi = (forgetForm) => axios({
    url: '/updatePassword',
    method: 'put',
    data: forgetForm
})

/**
 * 根据用户名密码登录
 * @param userId 用户名
 * @param userPassword 密码
 * @returns {*}
 */
export const loginByUsername = (userId, userPassword) => axios({
    url: '/login',
    method: 'post',
    meta: {
        isToken: false
    },
    data: {
        userId,
        userPassword,
    }
})

/**
 * 手机验证码登录
 * @param userId 手机号
 * @param checkCode 验证码
 * @returns {*}
 * @constructor
 */
export const LoginByPhoneApi = (userId, checkCode) => axios({
    url: '/loginByPhone',
    method: 'post',
    data:{
        userId,
        checkCode
    }
})
